const Sequelize = require('sequelize')

const dbScopes = require('@core/db-scopes')
let { user, host, port, database, password } = require("../config/hangao");

const sequelize = new Sequelize(database, user, password, {
    dialect: 'highgo',
    host,
    port,
    logging: false,
    timezone: '+08:00',
})

// 创建模型
sequelize.sync({ force: false })

console.warn("001")
sequelize
    .authenticate()
    .then(res => {
        console.warn("002")
        console.log('瀚高008 Connection has been established successfully.')
    })
    .catch(err => {
        console.warn("003")
        console.error('Unable to connect to the database:', err)
    })
    console.warn("004")
// sequelize.query("CREATE DATABASE IF NOT EXISTS boblog DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci").then(res=>{
//   console.log('CREATE DATABASE SUCCESS!')
// }).catch(err => {
//   console.log('CREATE DATABASE FAIL!', err)
// })

module.exports = {
    sequelize
}
